#ifndef STORAGE_H
#define STORAGE_H

#include <QNetworkAccessManager>
#include <QWidget>
#include <iostream>
#include "json/json.h"
#include <fstream>
#include <QObject>
#include <QString>
#include <QtNetwork>
#include <QJsonObject>
#include <QJsonDocument>

struct storagemessageInfo{
    int code;
    QString data;
    QString message;
};
struct storageInfo{
    QString alias;
    int amount;
    int foodId;
    int fridgeId;
    QString info;
    QString name;
    QString pic;
    QString type;
    QString unit;
    int userId;
};
class Storage : public QObject
{
    Q_OBJECT
public:
    explicit Storage(QObject *parent = nullptr);
    QNetworkAccessManager *accessManager;
    QNetworkRequest request;
    QByteArray postData;
    QNetworkReply* reply;
    storagemessageInfo s_message;
    QList<storageInfo> storagelist;
    void storageAdd(QString token,QString amount,int foodId,int fridgeId,int userId);
    void storageDelete(QString token,QString alias,int amount,int foodId,int fridgeId,QString info,QString name,QString pic,QString type,QString unit,int userId);
    void storageList(QString token,int filter);
    void storageUpdate(QString token,QString alias,int amount,int foodId,int fridgeId,QString info,QString name,QString pic,QString type,QString unit,int userId);
private slots:
    void finishedSlot(QNetworkReply *reply);
signals:
    void storageAddSuccess();
    void storageDeleteSuccess();
    void storageListSuccess();
    void storageUpdateSuccess();
};

#endif // STORAGE_H
